<template>
  <div class="AddOrUpdate_main add_container column_three">
    <div class="main_main ">
      <el-form ref="form" :model="showData" :inline="true">
        <el-tabs v-model="activeName">
          <el-tab-pane v-for="(item,index) in showKey" :key="index" :label="item.name" :name="index+1+''">
            <div
              v-for="(item2,index2) in item.columns"
              :key="index2"
              :class="getClass(item2)"
            >
              <el-form-item v-if="item2.type=='form'" :label="item2.name">
                <div v-if="!showData[item2.key]&&showData[item2.key]!==0&&showData[item2.key]!=='0'" class="show noData">暂无</div>
                <div v-else class="show">{{ showData[item2.key] }}</div>
              </el-form-item>
              <el-form-item v-if="item2.type=='file'" :label="item2.name">
                <FileManageFull
                  :file-names="showData[item2.fileName]"
                  :file-real-names="showData[item2.fileRealName]"
                  :file-urls="showData[item2.fileUrl]"
                  :row-index="1"
                  :readonly="true"
                  @fileName="setFileName"
                />
              </el-form-item>
              <div v-if="item2.type=='table'">
                {{ item2.name }}
              </div>
              <div v-if="item2.type=='table'" ref="table_container" class="table_container">
                <el-table
                  ref="table"
                  :data="showData[item2.key]"
                  stripe
                  border
                  row-key="id"
                >
                  <el-table-column
                    v-for="(item3,index3) in item2.columns"
                    :key="index3"
                    :prop="item3.key"
                    :label="item3.name"
                    min-width="100"
                    show-overflow-tooltip
                  />
                </el-table>
              </div>
              <div v-if="item2.type=='tableOne'" ref="table_container1" class="table_container draggableTable addRow_table">
                <el-table
                  ref="table"
                  :data="showData[item2.key]"
                  stripe
                  border
                  row-key="id"
                  style="width: 99.9%"
                >
                  <el-table-column type="expand">
                    <template slot-scope="props">
                      <el-form label-position="left" class="expand_container">
                        <el-form-item label="保养结果" class="expand_radio">
                          <div class="show">
                            <svg-icon v-if="props.row.result==1" icon-class="勾" />
                            <svg-icon v-else-if="props.row.result==0" icon-class="叉" />
                            <div v-else>暂无</div>
                          </div>
                        </el-form-item>
                        <el-form-item label="现场照片" class="expand_file file double">
                          <FileManageFull
                            :file-names="props.row.docName"
                            :file-real-names="props.row.docRealName"
                            :file-urls="props.row.docUrl"
                            :row-index="props.$index"
                            :readonly="true"
                            @fileName="setFileName"
                          />
                        </el-form-item>
                        <el-form-item label="保养记录" class="double">
                          <div class="show">{{ props.row.description?props.row.description:'暂无' }}</div>
                        </el-form-item>
                        <el-form-item label="备注" class="double">
                          <div class="show">{{ props.row.remark?props.row.remark:'暂无' }}</div>
                        </el-form-item>
                      </el-form>
                    </template>
                  </el-table-column>
                  <el-table-column
                    type="index"
                    width="50"
                    label="序号"
                  />
                  <el-table-column prop="name" label="保养项目">
                    <template slot-scope="scope">
                      <DivTextarea :row-value="scope.row.name" />
                      <!-- <div>{{ scope.row.name }}</div> -->
                      <!-- <el-input v-model="scope.row.name" style="margin:10px 0;" type="textarea" autosize /> -->
                    </template>
                  </el-table-column>
                  <el-table-column prop="content" label="保养内容">
                    <template slot-scope="scope">
                      <DivTextarea :row-value="scope.row.content" />
                      <!-- <el-input v-model="scope.row.content" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                    </template>
                  </el-table-column>
                  <el-table-column prop="way" label="保养方式">
                    <template slot-scope="scope">
                      <DivTextarea :row-value="scope.row.way" />
                      <!-- <el-input v-model="scope.row.way" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="time"
                    label="时间 ( S )"

                    :min-width="SETTINGS.settings_decimalDigits_length"
                  >
                    <template slot-scope="scope">
                      <DivTextarea :row-value="scope.row.time" />
                      <!-- <el-input v-model="scope.row.time" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                    </template>
                  </el-table-column>
                  <el-table-column prop="time" label="至少上传张数" width="140">
                    <template slot-scope="scope">
                      <DivTextarea :row-value="scope.row.minPage?scope.row.minPage+'':''" />
                      <!-- <el-input v-model="scope.row.time" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                    </template>
                  </el-table-column>
                  <el-table-column prop="criterion" label="判断标准">
                    <template slot-scope="scope">
                      <DivTextarea :row-value="scope.row.criterion" />
                      <!-- <el-input v-model="scope.row.criterion" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="附件"
                    min-width="120"
                  >
                    <template slot-scope="scope">
                      <FileManage
                        :file-names.sync="scope.row.fileName"
                        :file-real-names.sync="scope.row.fileRealName"
                        :file-urls.sync="scope.row.fileUrl"
                        :readonly="true"
                        class="accessory"
                      />
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-form>
    </div>
  </div>
</template>

<script>
import DivTextarea from '@/components/JLink/common/DivTextarea.vue'
export default {
  name: 'ShowDetail',
  components: {
    DivTextarea
  },
  props: {
    layerid: {},
    showKey: {},
    showData: {}
  },
  data() {
    return {
      pageId: '查看', // 页面唯一标识
      activeName: '1',
      tableHeight: '450'
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.tableHeight = this.$refs.table_container[0].offsetHeight
    })
  },
  methods: {
    cellClassName(data) {
      if (data.column.property == 'operate') {
        if (data.rowIndex % 2 == 0) { // 单数行
          return 'fixed one'
        } else { // 双数行
          return 'fixed two'
        }
      }
    },
    rowClassName({ row, rowIndex }) {
      if (rowIndex == this.formData.spareList.length - 1) {
        return 'addRow'
      }
    },
    setFileName(...data) {
      this.tableData[data[3]].fileName = data[0]
      this.tableData[data[3]].fileRealName = data[1]
      this.tableData[data[3]].fileUrl = data[2]
    },
    getClass(item) {
      let res = ''
      if (item.type == 'form') {
        res += 'showItem'
        if (item.length && item.length == 'double') {
          res += ' double'
        }
      } else {
        res += 'showTable'
      }

      return res
    }
  }
}
</script>

<style lang="less" scoped>
.accessory {
  color: #387bfc
}
/deep/ .el-textarea__inner{
  // border: none !important;
  // background: none;
  overflow: hidden;
}
.main_main{
  padding-top: 0px;
  /deep/ .el-form--inline {
    height: 100%;
    .el-tabs{
      height: 100%;

      .el-tabs__content{
        height: calc(100% - 40px);
      }
    }
    .el-tabs__header {
      margin: 0px !important;
    }
  }
  .el-form{
    height: 100%;
    align-content: flex-start;
    .showItem{
      margin-left: 20px;
      margin-right: 20px;
      width: calc(33.33% - 40px);
    }

    /deep/ .el-form-item{
      width: 100%;
      border-bottom: 1px solid #D6D6D6;
      margin-left: 0;
      margin-right: 0;
      margin-bottom: 0;
      .el-form-item__label:before{
        content: none;
      }
      .el-form-item__label{
        color: #1F51B3;
        font-size: 15px;
      }
      .el-form-item__label{
        width: 120px !important;
        margin-top: 10px;
      }
      .el-form-item__content{
        word-break: break-all;
        color: #333333;
        font-size: 15px;
        flex: 1;
        width: unset;
        margin-right: 0px;
      }
    }
    .double{
      width: calc(100% - 40px);
      //height: auto;
      ///deep/ .el-form-item__content{
      //  height: auto;
      //}
      ///deep/ .el-form-item{
      //  height: auto;
      //}
      //.show{
      //  overflow: hidden;
      //  text-overflow: ellipsis;
      //  display: -webkit-box;
      //  -webkit-line-clamp: 2;
      //  -webkit-box-orient: vertical;
      //}
    }
    .showTable{
      width: 100%;
      //height: 100%;
      padding-top: 20px;
      /deep/  .el-form-item{
        .el-form-item__label {
          margin-top: 10px !important;
          margin-bottom: 10px !important;
        }
      }
    }
  }
  .column_one{
    .showItem{
      width: 100% !important;
    }
  }
  /deep/ .el-tab-pane{
    align-content: flex-start;
  }
}
.column_one{
  .showItem{
    width: 100% !important;
  }
}
.show{
  height: fit-content !important;
  padding-top: 10px;
  padding-bottom: 10px;
}
.FileManageFull_container{
  padding-top: 10px;
  padding-left: 10px;
}
.noData{
  color: #c0c4cc;
}
/deep/ .el-tab-pane{
  overflow-y: overlay;
}

// /deep/ .el-table {
//   height: 100% !important;
// }
// /deep/ .el-table th.el-table__cell>.cell{
//   position:unset;
// }
// .table_container{
//   /deep/ .el-form-item{
//     border-bottom: 0 !important;
//     width: calc(100% - 40px) !important;
//     margin-left: 20px !important;
//     margin-right: 20px !important;
//     .el-form-item__label:before{
//       content: none;
//     }
//     .el-form-item__label{
//       width: 140px !important;
//       margin-top: 10px;
//     }
//     .el-form-item__content{
//       flex: 1;
//       width: unset;
//       margin-right: 0px;
//     }
//     /deep/.is-scrolling-none {
//       margin-bottom: 8px !important;
//     }
//   }
// }
// .el-table {
//   font-size: 15px;
// }
</style>
